function [] = plot_all_traces(ROIs,bv,np,scan_info)
% plots all ROI activity traces


% read scan info
nr_conditions=1;
for ind=1:length(scan_info{1})
    if strcmp(scan_info{1}{ind},'total frames');
        frames.total=str2num(scan_info{2}{ind});
    elseif strcmp(scan_info{1}{ind},'on');
        frames.on=str2num(scan_info{2}{ind});
    elseif strcmp(scan_info{1}{ind},'off');
        frames.off=str2num(scan_info{2}{ind});
    elseif strcmp(scan_info{1}{ind},'repetitions');
        reps=str2num(scan_info{2}{ind});
    elseif strcmp(scan_info{1}{ind},'orientations');
        orientations=str2num(scan_info{2}{ind});
    elseif strcmp(scan_info{1}{ind},'stim conditions');
        nr_conditions=textscan(scan_info{2}{ind},'%[^ ]');
        nr_conditions=length(nr_conditions{1});
    end
end



% generate the on/off shading
shading.x(1)=0;
shading.y(1)=0;
for ind=2:4*frames.total/(frames.on+frames.off)
    if rem(ind,2)==1
        shading.x(ind)=shading.x(ind-1);
    elseif rem(ind,4)==0
        shading.x(ind)=shading.x(ind-1)+frames.on;
    else
        shading.x(ind)=shading.x(ind-1)+frames.off;
    end
    if rem(ind-1,4)>1 
        shading.y(ind)=1;
    else
        shading.y(ind)=0;
    end
end

for ind=1:length(ROIs)
    data(:,:,ind)=reshape(calc_dFF(ROIs(ind).activity),frames.total/reps,reps)';
    %data(:,:,ind)=data(:,:,ind)/max(max(data(:,:,ind)));
end

np_act=reshape(calc_dFF(np.activity),reps,frames.total/reps);
bv_act=reshape(calc_dFF(bv.activity),reps,frames.total/reps);

hf = figure;
hold on
cla
%area(shading.x,0.2*shading.y,'edgecolor','none','facecolor',[1 1 1]*0.1)

for ind=1:size(data,3)
    plot(data(:,:,ind)'+ind*0.1);
end

1;


% 
% aaa=squeeze(mean(data,1));
% bbb(1,:)=mean(aaa(1:120,:));
% bbb(2,:)=mean(aaa(121:240,:));
% % bbb(3,:)=mean(aaa(241:360,:));
% % bbb(4,:)=mean(aaa(361:480,:));
% 
% for ind=1:length(bbb)
%     avg_act(ind)=mean(bbb(:,ind));
%     bbb(:,ind)=bbb(:,ind)-mean(bbb(:,ind));
% end
% 
% c_id=kmeans(bbb',6);
% [a,b]=sort(c_id);
% 
% figure;imagesc(bbb(:,b)')
% 
% clrind='rgbyck';
% figure;
% hold on
% for ind=1:length(bbb)
%     if avg_act(ind)>mean(avg_act)
%     plot(bbb(:,ind),'color',clrind(c_id(ind)),'linewidth',2);
%     else
%         plot(bbb(:,ind),':','color',clrind(c_id(ind)));
%     end
% end
% 
% 
% 
% 





